package com.ygq.manageGame.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.ygq.manageGame.bean.Game;
import com.ygq.manageGame.bean.Manage;
import com.ygq.manageGame.service.GameService;
import com.ygq.manageGame.service.ManageService;
import com.ygq.manageGame.util.Result;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class LoginController {
    @Resource
    private ManageService manageService;

    @PostMapping("/login")
    public Result login(@Validated @RequestBody Manage manage){
      //  QueryChainWrapper<Game> query = gameService.query(manage);
        if(manageService.CheckManageExist(manage)){
            return Result.success();
        }else {
            return Result.error(444,"用户不存在,请验证信息重新登录");
        }
    }

    @RequestMapping("/register")
    public Result Resister(@Validated @RequestBody Manage manage) {
        if (manageService.CheckManageExist(manage)) {
            return Result.error(444, "用户已存在");
        } else if (manageService.RegisterAdmin(manage)) {

            return Result.success();
        }
        return Result.error(444,"用户注册失败，请稍后再试");
    }





}
